<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button onclick="next()">
    next()
</button>
<button onclick="back()">
    back()
</button>
<script>
    /*
    p527
      5. pageshow 和 pagehide事件
          - 用户前进和后退时候的缓存
          - 虽然这个事件的目标是 document，但事件处理程序必须添加到 window 上
   */
    (function () {
        let showCount = 0;
        window.addEventListener("load", () => {
            console.log("Load fired");
        });
        window.addEventListener("pageshow", () => {
            showCount++;
            console.log(`Show has been fired ${showCount} times.`,
            `Persisted?${event.persisted}`);
        });
    })();
    
    function next() {
        location.href='https://www.dogedoge.com'
    }

</script>
</body>
</html>